package com.LeeCode;

/**
 * 猜数字大小
 */

public class Code374 {
    public static void main(String[] args) {

    }

    public int guessNumber(int n) {
        int left = 0, right = n;
        while (left + 1 < right) {
            int mid = left + (right - left) / 2;
            if (guess(mid) == 0) {
                return mid;
            } else if (guess(mid) == -1) {
                right = mid;
            } else {
                left = mid;
            }
        }
        return right;
    }

    private int guess(int num) {
        return num;
    }
}
